﻿using EFEntity;
using Iservices;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class first_kindServices : Ifirst_kindServices
    {
        private readonly MyDbContext myDbContext;

        public first_kindServices(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }

        //public async Task<int> Add(config_file_first_kind fd)
        //{
        //    Econfig_file_first_kind test = new Econfig_file_first_kind()
        //    {
        //        ffk_id = fd.ffk_id,
        //        first_kind_sale_id = fd.first_kind_sale_id,
        //        first_kind_name = fd.first_kind_name,
        //        first_kind_salary_id = fd.first_kind_salary_id,
        //        first_kind_id = fd.first_kind_id
        //    };
        //    myDbContext.config_file_first_kind.Attach(test);
        //    myDbContext.Entry(test).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
        //    int result = await myDbContext.SaveChangesAsync();
        //    return result;
        //}

        public Task<int> Delete(int id)
        {
            throw new NotImplementedException();
        }

        public Task<config_file_first_kind> seleceById(int id)
        {
            throw new NotImplementedException();
        }

        public async Task<List<config_file_first_kind>> selectAll()
        {
            List<Econfig_file_first_kind> list = new List<Econfig_file_first_kind>();
            await Task.Run(() =>
            {
                list = myDbContext.config_file_first_kind.ToList();
            });
            List<config_file_first_kind> list2 = new List<config_file_first_kind>();
            foreach (Econfig_file_first_kind item in list)
            {
                config_file_first_kind fd = new config_file_first_kind()
                {
                    ffk_id = item.ffk_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    first_kind_sale_id = item.first_kind_sale_id,
                    first_kind_salary_id = item.first_kind_salary_id
                };
                list2.Add(fd);
            }
            return list2;
        }

        public Task<int> update(config_file_first_kind fd)
        {
            throw new NotImplementedException();
        }
    }
}
